<template>
	<view>
		<TabMenu :menus="tabList" :active_line="true" :tabCur="tabCur" ref="tableMenu" @clickCtTab="clickCtTab">
		</TabMenu>
		<view v-if="list.length>0">
			<view class="txsh_info" v-for="(item, index) in list" :key="item.id">
				<view class="info_header">
					<text>订单号：{{item.no}}</text>
					<text class="f_red" v-if="item.state==0">待处理</text>
				</view>
				<view class="info_c1">
					<text>提现金额：{{item.withDrawalMoney}}</text>
					<text v-if="item.withDrawalWay==0">提现方式：ZFB</text>
					<text v-if="item.withDrawalWay==1">提现方式：WX</text>
					<text v-if="item.withDrawalWay==2">提现方式：YHK</text>
					<text>姓名：{{item.userName}}</text>
				</view>
				<view class="info_c2">
					<view class="c2_item">
						<text>手机号：{{item.phone}}</text>
						<view class="copy_btn" @click="clipboardData(item.phone)">复制信息</view>
					</view>
					<view class="c2_item">
						<text>邀请码：{{item.invitationCode}}</text>
						<view class="copy_btn" @click="clipboardData(item.invitationCode)">复制信息</view>
					</view>
					<view class="c2_item m_b10">
						<text>提现时间：{{item.withDrawalTime}}</text>
					</view>
					<view class="c2_item m_b10" v-if="item.state!=0">
						<text>审核状态</text>
						<view class="copy_btn" style="background: darkgray">{{item.state==1?'已通过':'已拒绝'}}</view>
					</view>
				</view>
				<view class="info_footer">
					<view class="wds_btn" v-if="item.state==0" @click="update(item.id,1)">同意</view>
					<view class="wds_btn" v-if="item.state==0" @click="update(item.id,2)">拒绝</view>
				</view>
			</view>
		</view>
		<Nodata v-else></Nodata>

	</view>
	</view>
</template>

<script>
	import {
		getList,
		updateState
	} from '@/request/api/withDrawStatus.js'
	import TabMenu from '@/components/TabMenu.vue'
	import Nodata from '@/components/Nodata.vue'
	export default {
		components: {
			TabMenu,
			Nodata
		},
		activated() {
			this.tabCur = uni.getStorageSync('abc') // 输出 'value1'
			this.$refs.tableMenu.clickCtTab(this.tabCur)
		},
		mounted() {
			this.tabCur = uni.getStorageSync('abc') // 输出 'value1'
			this.$refs.tableMenu.clickCtTab(this.tabCur)
		},
		onHide() {
			uni.setStorageSync('abc', 0)
		},
		data() {
			return {
				tabCur: 0,
				tabList: [{
					title: '待审提现',
				}, {
					title: '已审提现',
				}],
				list: [{
					id: '', //提现记录id,
					userId: '', //用户ID
					withDrawalMoney: '', //提现金额
					withDrawalWay: '', //0: 支付宝收款,1:微信收款;2:银行卡收款
					withDrawalTime: '', //提现时间
					createTime: '', //日期
					storeId: '', //店铺id
					storeName: '', //店铺名称
					state: '', //0:待转转,1:已经打款,2:失败
					no: '', //单号,
					userName: '', //用户姓名
					phone: '', //用户电话
					invitationCode: '', //邀请码
				}]
			};
		},
		methods: {
			clickCtTab(ctCur) {
				this.tabCur = ctCur
				this.getDateList(this.tabCur)
			},
			async getDateList(state) {
				const res = await getList(state)
				this.list = res.data
			},
			async update(id, state) {
				const res = await updateState(id, state)
				if (res.code == 0) {
					uni.showToast({
						title: '修改成功'
					})
				}
			},
			clipboardData(data) {
				uni.setClipboardData({
					data: data, // 设置要复制的文本内容
					success(res) {
						uni.showToast({
							title: '复制成功'
						})
					},
					fail(err) {
						uni.showToast({
							title: '复制失败'
						})
					}
				});
			},
		},
		onLoad() {
			this.list = []
		}
	}
</script>

<style lang='scss' scoped>
	.f_red {
		color: #fc4141;
	}

	.txsh_info {
		display: flex;
		flex-direction: column;
		margin-top: 20px;
		background: white;
		color: #999;
		padding: 0 15px;
	}

	.txsh_info .info_header {
		display: flex;
		flex-direction: row;
		border-bottom: .5px solid #eee;
		justify-content: space-between;
		height: 49px;
		align-items: center;
	}

	.info_c1 {
		display: flex;
		flex-direction: column;
		margin: 10px 0px;
	}

	.info_c2 {
		display: flex;
		flex-direction: column;
		border-bottom: .5px solid #eee;
	}

	.info_c2 .c2_item {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		height: 32px;
	}

	.m_b10 {
		margin-bottom: 10px;
	}

	.info_c2 .c2_item .copy_btn {
		width: 80px;
		height: 30px;
		background: #2866f9;
		color: white;
		border-radius: 10px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.info_footer {
		display: flex;
		flex-direction: row;
		justify-content: end;
		padding: 11px 0;
	}

	.wds_btn {
		border-radius: 5px;
		border: 2px solid #fc4141;
		color: #fc4141;
		width: 50px;
		height: 30px;
		line-height: 30px;
		text-align: center;
		margin-left: 10px;
	}
</style>